package cc.admin.modules.sys.mapper;

import cc.admin.modules.sys.entity.SysOrg;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.data.repository.query.Param;

import java.util.List;


public interface SysOrgMapper extends BaseMapper<SysOrg> {

	@Select("select id from sys_org where code=#{code}")
	public String queryIdByCode(@Param("code") String code);

	@Select("select name from sys_org where code=#{code}")
	public String queryNameByCode(@Param("code") String code);

	@Select("select id,parent_id from sys_org where id=#{id}")
	public SysOrg getParentOrgId(@Param("id") String id);

	/**
	 *  根据机构Id查询,当前和下级所有机构IDS
	 * @param id
	 * @return
	 */
	List<String> getSubIdsById(@Param("id") String id);

	/**
	 * 根据机构编码获取机构下所有IDS
	 * @param codes
	 * @return
	 */
	List<String> getSubIdsByCodes(@Param("codes") String[] codes);

}
